<?php
session_start();
$code = $_SESSION["code"];
$yanzhengma = $_REQUEST["code"];
if ($code != $yanzhengma)
{
	exit("验证码错误");
}
include "connect.php";
$name		= $_REQUEST['name'];
$password	= $_REQUEST['password'];
$ins = "select count(*) from user where name='$name'";
$result = mysql_query($ins,$dbLink);
$row = mysql_fetch_row($result);
$count = $row[0];
if ($count > 0)
{
	echo "<script>alert('用户已被注册！');</script>";
	echo "<script>window.location='register.php';</script>";
} 
else 
{ 
	$ins="insert into user (name,password) values ('{$name}','{$password}')";
	$result=mysql_query($ins,$dbLink);
	if ($result)
	{ 
		echo "<script>alert('用户注册成功！');</script>";
		echo "<script>window.location='login.php';</script>";
	}
}
?>
